﻿using IBLL;
using IBLL.Dto;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model;

namespace GetPeople.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class HodeController : ControllerBase
    {
        public HodeController(IHodeBLL bLL)
        {
            BLL = bLL;
        }

        public IHodeBLL BLL { get; }

        [HttpPost]
        public Task<int> AddAsync(Hode hode)
        {
            try
            {
                return BLL.AddAsync(hode);
            }
            catch (Exception)
            {

                throw;
            }
            
        }
        [HttpDelete]
        public Task<int> DeleteAsync(int id)
        {
            try
            {
                return BLL.DeleteAsync(id);
            }
            catch (Exception)
            {

                throw;
            }
           
        }
        [HttpGet]
        public IQueryable<Hode> GetAll()
        {
            try
            {
                return BLL.GetAll();
            }
            catch (Exception)
            {

                throw;
            }
          
        }
        [HttpGet]
        public GetHodePageDto<Hode> GetHodePage(int index, int size, string? name)
        {
            try
            {
                return BLL.GetHodePage(index, size, name);
            }
            catch (Exception)
            {

                throw;
            }
          

        }

    }
}
